#include "qclientupdate.h"

#include <QFile>
#include <QApplication>
#include <QDir>

QClientUpdate::QClientUpdate()
{
}

void QClientUpdate::recv_data(const QByteArray &data)
{
    m_data+=data;
}

bool QClientUpdate::save()
{
    if(m_data.size()==0)
    {
        return false;
    }
    QString path=qApp->applicationDirPath()+"/update.db";
    QFile f(path);

    if(!f.open(QFile::WriteOnly))
    {
        return false;
    }

    f.resize(0);

    f.write(m_data);

    m_data.clear();

    return true;
}

void QClientUpdate::ready(const QString &uuid)
{
    m_server_uuid=uuid;
    m_data.clear();
}

QString QClientUpdate::get_server_uuid()
{
    return m_server_uuid;
}
